#!/usr/bin/env bash
# db-generate_series -- Generates a table holding given number of rows using MySQL
# > eval "$(db-parse "$url")"
# > db-generate_series TABLE COLUMN FIRST LAST [INCREMENT]
##
set -euo pipefail

[[ $# -gt 0 ]] || usage "$0" "Missing TABLE"
[[ $# -gt 1 ]] || usage "$0" "Missing COLUMN"
[[ $# -gt 2 ]] || usage "$0" "Missing FIRST"
[[ $# -gt 3 ]] || usage "$0" "Missing LAST"
Table=$1 Column=$2 First=$3 Last=$4 Increment=${5:-1}

db-create-table-def "$Table" "$Column":BIGINT

# generate numbers with seq(1) and add it to the table
seq $First $Increment $Last | db-load "$Table" tsv
# XXX there may be a more efficient solution for this
